home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUTORC.ZIP / TUT10.C < prev    next >
C/C++ Source or Header  |  1994-10-30  |  6KB  |  154 lines

  1. /* 
  2.   tut10.c
  3.   10/30/94
  4.   from tutprog10.pas
  5.   Adapted from Denthor's tutprog10.pas
  6.   Translated into C, from Denthor's VGA Trainer, by
  7.   Steve Pinault, scp@ohm.att.com
  8.   Compiled with Microsoft Visual C++ 1.5 (Microsoft C 8.0)
  9.   To compile:
  10.   First compile the subroutines in tutsubs.c with the batch file 
  11.   cltutsub.bat
  12.   Then compile any of the tutor programs with the batch file
  13.   cltut.bat
  14.   Example: C:>cltutsub
  15.            C:>cltut tut10.c
  16.            to compile this program.
  17. */
  18.  
  19. #include "tutheadr.h"
  20. #define Size 80
  21. //   { Size =  40 = 1 across, 4 down }
  22. //   { Size =  80 = 2 across, 2 down }
  23. //   { Size = 160 = 4 across, 1 down }
  24.  
  25. unsigned char bit[897]= {
  26. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,2,151,5,149,6,148,7,147,8,49,2,95,8,49,
  27. 4,93,9,49,3,93,4,2,3,49,4,92,4,3,3,48,4,92,4,3,4,48,4,91,4,4,3,48,4,92,4,3,4,
  28. 48,3,58,2,32,4,4,4,47,4,57,3,31,4,5,3,48,3,57,4,30,4,5,4,47,3,57,5,29,4,6,4,46,
  29. 4,57,4,29,4,7,3,47,3,58,2,30,4,7,4,46,4,90,4,7,4,46,3,90,4,8,4,27,2,16,3,90,4,
  30. 8,9,22,3,16,3,89,4,5,13,8,6,8,3,15,3,90,4,2,15,6,10,6,3,16,3,6,1,21,1,9,2,7,1,
  31. 21,6,14,18,9,5,2,4,5,4,1,4,10,3,4,5,10,2,7,3,8,2,5,3,9,3,7,8,13,13,1,4,9,4,5,3,
  32. 5,3,1,6,9,3,3,6,9,4,5,4,8,3,3,4,9,3,6,9,11,10,6,4,8,4,6,3,4,11,8,3,2,7,9,5,4,4,
  33.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,4,6,7,3,4,6,5,3,8,7,2,4,4,4,
  46. 19,3,5,10,5,3,1,6,11,3,7,3,16,5,7,4,4,5,6,3,8,6,3,5,3,4,19,3,6,9,5,3,18,2,25,5,
  47. 9,3,6,3,7,2,10,3,6,4,3,3,20,3,8,5,6,3,44,6,10,2,39,3,3,2,22,2,19,3,43,7,101,3,
  48. 42,8,102,3,41,4,1,4,101,4,39,5,2,3,102,3,39,4,4,3,102,3,38,4,4,4,101,3,38,4,5,
  49. 3,102,3,37,4,5,4,101,4,36,4,6,3,102,3,37,3,6,4,102,3,36,4,6,3,102,3,37,3,6,3,
  50. 103,3,37,3,5,4,102,4,37,3,4,4,103,3,38,10,104,3,38,9,105,2,40,7,106,2,41,4,0};
  51.  
  52.  
  53. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  54. // Procedure Putpic (x,y:integer);
  55. //   { This put's the picture at coordinates x,y on the chain-4 screen }
  56. void Putpic(int x, int y)
  57. {
  58.   int loop1,loop2;
  59.   int depth,cur;
  60.   depth=1;
  61.   cur=0;
  62.   for(loop1=0;loop1<897;loop1++)
  63.   {
  64.      for(loop2=1;loop2<=bit[loop1];loop2++)
  65.      {
  66.        if(cur!=0)C4PutPixel ((depth%155)+x,(depth/155)+y,(char)(depth/155),Size);
  67.        depth++;
  68.      }
  69.      cur=(cur+1)%2;
  70.    }
  71. }
  72.  
  73.  
  74. //Procedure Play;
  75. void Play()
  76. {
  77.   int loop1,loop2;
  78.   int xpos,ypos,xdir,ydir;
  79.   int ch;
  80.    for(loop1=1;loop1<=62;loop1++)
  81.      Pal ((char)loop1,(char)loop1,(char)0,(char)(62-loop1)); // { This sets up the pallette for the pic }
  82.  
  83.    moveto(0,0,Size); // { This moves the view to the top left hand corner }
  84.  
  85.    for(loop1=0;loop1<=3;loop1++)
  86.      for(loop2=0;loop2<=5;loop2++)
  87.        Putpic (loop1*160,loop2*66); // { This places the picture all over the
  88.                                     //  chain-4 screen }
  89.    getch();
  90.    ch=0x0;
  91.    xpos=random (78)+1;
  92.    ypos=random (198)+1; // { Random start positions for the view }
  93.    xdir=1;
  94.    ydir=1;
  95.    while(1)
  96.    {
  97.      WaitRetrace();     //     { Take this out and watch the screen go crazy! }
  98.      moveto (xpos,ypos,Size);
  99.      xpos=xpos+xdir;
  100.      ypos=ypos+ydir;
  101.      if( (xpos>79)  || (xpos<1))xdir=-xdir;
  102.      if( (ypos>199) || (ypos<1))ydir=-ydir; // { Hit a boundry, change
  103.                                             //    direction! }
  104.      if(_bios_keybrd(_KEYBRD_READY))ch=getch();
  105.      if(ch==0x71)break; // 'q'
  106.      if(ch==0x1b)break; // 'ESC'
  107.    }
  108. }
  109.  
  110. void main()
  111. {
  112.   _clearscreen(_GCLEARSCREEN);
  113.   InitChain4(Size);
  114.   Play();
  115.   FadeDown();
  116.   SetText();
  117. }
  118. /*
  119.   writeln ('Hello there! Here is the tenth tutorial, on Chain-4! You will notice');
  120.   writeln ('that there are two pascal files here : one is a unit containing all');
  121.   writeln ('our base graphics routines, and one is the demo program.');
  122.   writeln;
  123.   writeln ('In the demo program, we will do the necessary port stuff to get into');
  124.   writeln ('Chain-4. Once in Chain-4 mode, I will put down text saying ASPHYXIA');
  125.   writeln ('over the entire screen. After a key is pressed, the viewport will');
  126.   writeln ('bounce around, displaying the entire Chain-4 screen. The program will');
  127.   writeln ('end when [ESC] is pressed. The code here is really basic (except for');
  128.   writeln ('those port values), and should be very easy to understand.');
  129.   writeln;
  130.   writeln;
  131.   Write ('  Hit any key to contine ...');
  132.   Readkey;
  133.   initChain4;
  134.   play;
  135.   SetText;
  136.   Writeln ('All done. This concludes the tenth sample program in the ASPHYXIA');
  137.   Writeln ('Training series. You may reach DENTHOR under the names of GRANT');
  138.   Writeln ('SMITH/DENTHOR/ASPHYXIA on the ASPHYXIA BBS. I am also an avid');
  139.   Writeln ('Connectix BBS user, and occasionally read RSAProg. E-mail me at :');
  140.   Writeln ('    smith9@batis.bis.und.ac.za');
  141.   Writeln ('The numbers are available in the main text. You may also write to me at:');
  142.   Writeln ('             Grant Smith');
  143.   Writeln ('             P.O. Box 270');
  144.   Writeln ('             Kloof');
  145.   Writeln ('             3640');
  146.   Writeln ('             Natal');
  147.   Writeln ('             South Africa');
  148.   Writeln ('I hope to hear from you soon!');
  149.   Writeln; Writeln;
  150.   Write   ('Hit any key to exit ...');
  151.   Readkey;
  152. END.
  153. */
  154.